﻿using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.ServiceModel.DomainServices.Server;
using System.ComponentModel.DataAnnotations;

namespace NetBay.Core.BusinessEntities
{
    [DataContract]
    public class NumerizationOperatorByDate : ReturnObject, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private string _fullName;
        private List<NumerizationFoldersByDate> _nbFoldersProcessedByDate = new List<NumerizationFoldersByDate>();

        [DataMember]
        public string FullName
        {
            get { return _fullName; }
            set
            {
                _fullName = value;
                OnPropertyChanged("FullName");
            }
        }

        private long _userId;
        
        [DataMember]
        public long UserId
        {
            get { return _userId; }
            set 
            { 
                _userId = value;
                OnPropertyChanged("UserId");
            }
        }

        [Association("NbFoldersProcessedByDate", "Key", "ForeignKey")]
        [Include]
        [DataMember]
        public List<NumerizationFoldersByDate> NbFoldersProcessedByDate
        {
            get { return _nbFoldersProcessedByDate; }
            set
            {
                _nbFoldersProcessedByDate = value;
                ItemEntity.SetForeignKey(_nbFoldersProcessedByDate, Key);
                OnPropertyChanged("NbFoldersProcessedByDate");
            }
        }

        /// <summary>
        /// Sets the nb folders processed by date values.
        /// </summary>
        /// <param name="nbFoldersProcessedByDate">The nb folders processed by date.</param>
        public void SetNbFoldersProcessedByDateValues(List<NumerizationFoldersByDate> nbFoldersProcessedByDate)
        {
            NbFoldersProcessedByDate = nbFoldersProcessedByDate;
        }

        /// <summary>
        /// Called when [property changed].
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        protected void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
